package acount;
import book.Booklist;
import operation.IOperation;
public abstract class User {
    protected static String[] username = new String[] {"Mattylyh","654198530","15015070393"};
    protected static String[] password = new String[] {"2017","100","69"};

    public abstract void menu();

    /**
     * 实例化对象后 子类对象可以通过this.直接调用该数组
     *
     */
    protected IOperation[] iOperations;

    public void operate(int c, Booklist booklist) {
        this.iOperations[c].work(booklist);
        /**
         * 这句话什么意思a
         * 执行iOperations中的c下标的IOperation操作，如
         * 有this表示调用的是User子类对象的数组
         * 没有this就不一定？
         */
    }

    public static int getPos (String name) {
        int i = 0;
        for (i = 0; i<3; i++) {
            if (name.equals(username[i])){
                return i;
            }
        }
        return -1;
    }

    public static int getPass (String pass) {
        int i = 0;
        for(i = 0; i <3; i++) {
            if (pass.equals(password[i])) {
                return i;
            }
        }
        return -1;
    }
}
